<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="static/easyui/themes/icon.css">
<link rel="stylesheet" href="static/css/style.css" />
<link rel="stylesheet" href="static/css/tcommon.css" />
<script src="static/jquery/jquery-1.12.4.js"></script>
<script src="static/easyui/jquery.easyui.min.js"></script>
<script src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<title>摄像头</title>
</head>

<body class="easyui-layout">
	<div data-options="region:'center'" title="摄像头列表">
		<table id="pro_table" class="easyui-datagrid" style="height: 100%">
		</table>
	</div>
	<div id="pro_tb">
		<div class="search-input">
				项目：
				<input style="width: 200px;" id="projectitemid" name="projectitemid" class="easyui-combobox"
					editable="false"
					data-options="
							    valueField: 'id',
							    textField: 'name',
							    url: 'projectitemuserlist.do',
							    onSelect: function(rec){
							    	if(rec.projectitemchilds.length>0){
										var url = 'projectitemchildlist?projectitemid=' + rec.id;
										$('#projectitemchildid').combobox('reload', url);
										document.getElementById('div1').style.display = '';
							    	}else{
							    		projectitemid = rec.id;
							    		projectitemchildid = 0;
										$('#projectitemchildid').combobox('clear');
										document.getElementById('div1').style.display = 'none';
							    	}
							    },panelHeight: 'auto'">
			</div>
			<div id="div1" style="display: none;" class="search-input">
				子项目：
				<input style="width: 200px;" id="projectitemchildid" name="projectitemchildid" class="easyui-combobox"
					editable="false"
					data-options="
							    valueField: 'id',
							    textField: 'name',
							    onSelect: function(rec){
							    	projectitemchildid = rec.id;
							    },panelHeight: 'auto'">
			</div>
		<div class="search-input">
			<a href="#" class="easyui-linkbutton" iconCls="icon-search" id="search">搜索</a>
		</div>
	</div>
</body>
<script>
	var currentPro;
	var projectitemid;
	var projectitemchildid;
	$(document).ready(function() {
		$('#pro_table').datagrid({
			rownumbers : true,
			singleSelect : true,
			pagination : true,
			fitColumns : false,
			border : false,
			striped : true,
			toolbar : '#pro_tb',
			url : "camerauser",
			method : 'get',
			onSelect : function(index,row) {
				currentPro = row;
			},
			onDblClickRow : function(index,row) {
				currentPro = row;
				updatepro();
			},
			columns : [ [ {
				field : 'no',
				title : '序列号',
				width : ''
			},{
				field : 'name',
				title : '名称',
				width : ''
			},{
				field : 'location',
				title : '地点',
				width : ''
			},{
				field : 'handle',
				title : '操作',
				width : '100px',
				formatter : function(value,row,index) {
					return '<a class="c-orange" href="#" onclick="addTab(' + index + ')">进入监控</a>'
				}
			} ] ]
		});
	});
	function loadData() {
		if (projectitemchildid > 0){
			$('#pro_table').datagrid({
				rownumbers : true,
				singleSelect : true,
				pagination : true,
				fitColumns : false,
				border : false,
				striped : true,
				toolbar : '#pro_tb',
				url : "camerauser.do",
				method : 'get',
				queryParams : {
					projectitemchildid : projectitemchildid
				},
				onSelect : function(index,row) {
					currentPro = row;
				},
				onDblClickRow : function(index,row) {
					currentPro = row;
					updatepro();
				},
				columns : [ [ {
					field : 'no',
					title : '序列号',
					width : ''
				},{
					field : 'name',
					title : '名称',
					width : ''
				},{
					field : 'location',
					title : '地点',
					width : ''
				},{
					field : 'handle',
					title : '操作',
					width : '100px',
					formatter : function(value,row,index) {
						return '<a class="c-orange" href="#" onclick="addTab(' + index + ')">进入监控</a>'
					}
				} ] ]
			});
		}else{
			$('#pro_table').datagrid({
				rownumbers : true,
				singleSelect : true,
				pagination : true,
				fitColumns : false,
				border : false,
				striped : true,
				toolbar : '#pro_tb',
				url : "camerauser.do",
				method : 'get',
				queryParams : {
					projectitemid : projectitemid
				},
				onSelect : function(index,row) {
					currentPro = row;
				},
				onDblClickRow : function(index,row) {
					currentPro = row;
					updatepro();
				},
				columns : [ [ {
					field : 'no',
					title : '序列号',
					width : ''
				},{
					field : 'name',
					title : '名称',
					width : ''
				},{
					field : 'location',
					title : '地点',
					width : ''
				},{
					field : 'handle',
					title : '操作',
					width : '100px',
					formatter : function(value,row,index) {
						return '<a class="c-orange" href="#" onclick="addTab(' + index + ')">进入监控</a>'
					}
				} ] ]
			});
		}
	}
	$("#search").click(function() {
		projectitemid = $("#projectitemid").combobox('getValue');
		projectitemchildid = $("#projectitemchildid").combobox('getValue');
		loadData();
	});
	function addTab(index) {
		var item = $("#pro_table").datagrid('getRows')[index];
		var title = '监控-' + item.name;
		window.parent.window.addTab(title, "imouplayer.do?cameraid=" + item.id, item.id);
	}
</script>

</html>